<script src="<?php echo $baseurl?>public/ckeditor/ckeditor.js"></script>
<script src="<?php echo $baseurl?>public/ckeditor/adapters/jquery.js"></script>

<div class="breadcrumbwidget">
	<ul class="skins">
        <li><a href="default" class="skin-color default"></a></li>
        <li><a href="orange" class="skin-color orange"></a></li>
        <li>&nbsp;</li>
        <li class="fixed"><a href="" class="skin-layout fixed"></a></li>
        <li class="wide"><a href="" class="skin-layout wide"></a></li>
    </ul><!--skins-->
	<ul class="breadcrumb">
        <li><a href="">Home</a> <span class="divider">/</span></li>
        <li class="active">FAQ</li>
    </ul>
</div><!--breadcrumbwidget-->
<div class="pagetitle">
	<h1>Giao hàng tận nhà</h1> <span></span>
</div><!--pagetitle-->

<div class="maincontent">
<?php if(validation_errors()): ?>
    <div class="alert alert-error" style="margin: 10px 10px 10px 40px;">
      <button data-dismiss="alert" class="close" type="button">×</button>
      <?php echo validation_errors(); ?>
    </div>
<?php endif;?>
	<div class="contentinner content-dashboard">
    
    <?php $attr = array('class' => 'stdform'); echo form_open_multipart('', $attr)?>
        <p>
        	<label>Tiêu đề</label>
            <span class="field"><input type="text" name="title" class="input-xlarge" placeholder="Nhập tên ưu đãi" value="<?php echo $data ? $data->title : ''?>"/></span>
        </p>
        <p>
        	<label>Ảnh bài viết</label>
            <span class="field">
                <img src="<?php echo $data ? $imgbase.$data->features : ''?>" id="features_show_" style="display: inline-block; vertical-align: middle;width: 69px;height: 69px;border: 1px solid #CCC;background: #CCC;" onError="this.src='<?php echo $baseurl."public/theme/manage/img/gray_jean.png";?>'" />
                <input type="hidden" name="features_" id="features_" value="" />
                <input type="hidden" name="features_verify" id="features_verify" value="<?php echo $data ? $data->features : ''?>" />
                <input type="hidden" name="features_check" id="features_check" value="<?php echo $data ? $data->features : ''?>" />
                <input class="uniform-file" type="file" name="fileupload" id="features_upload" onchange="convertimage('features_upload', 'features_', 'features_show_', 'features_check');" value="" />
            </span>
        </p>
        <p>
        	<label>Nội dung</label>
            <span class="field"><textarea id="content_" name="content" cols="80" rows="5" class="span5"><?php echo $data ? $data->content : ''?></textarea></span>
        </p>
        <p>
            <label></label>
            <button class="btn btn-rounded" type="submit"> <i class="iconfa-ok"></i> &nbsp; Lưu</button>
        </p>
    </form>
    
    </div>
</div>




<script>

function convertimage(id, id_parse, img_show, check_image)
{
    var id = id;
    var id_parse = id_parse;
    var img_show = img_show;
    var check_image = check_image;
    var filesSelected = document.getElementById(id).files;
    if (filesSelected.length > 0)
    {
        var fileToLoad = filesSelected[0];

        var fileReader = new FileReader();

        fileReader.onload = function(fileLoadedEvent) 
        {
            $("#"+id_parse).attr('value', fileLoadedEvent.target.result);
            $("#"+check_image).val('1');
            //document.getElementById('cddd').html(fileLoadedEvent.target.result);
            $("#"+img_show).attr('src', fileLoadedEvent.target.result);
        };

        fileReader.readAsDataURL(fileToLoad);
    }
}
</script>
<script type="text/javascript">
        CKEDITOR.replace( 'content_', {  enterMode : CKEDITOR.ENTER_BR, shiftEnterMode : CKEDITOR.ENTER_BR } );
        CKEDITOR.on( 'instanceReady', function( ev )
        {
         ev.editor.dataProcessor.writer.setRules( 'br',
         {
            indent : false,
            breakBeforeOpen : false,
            breakAfterOpen : false,
            breakBeforeClose : false,
            breakAfterClose : false
  });
  });
</script>